home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
DB_CLIPP
/
2614.ZIP
/
TBROWS.ZIP
/
TTBR2.PRG
< prev
next >
Wrap
Text File
|
1990-10-22
|
4KB
|
166 lines
/*****
*
* TTBR2.PRG
* Second example for TBROWSE class using a database file
*
* 19 October 90
* Luiz Quintela - Nantucket Corp
*
* Clipper ttbr2 /N/W/A/B
* RTLINK FILE ttbr2 PLL base50
*
*/
// Include Header Files
// This will make handling keystrokes
// a bit easier!
#include "inkey.ch"
FUNCTION Main()
// Your variables
LOCAL b, column, nKey
SET SCOREBOARD OFF
SET DATE BRITISH
SET CONFIRM ON
// First open your file, with indexes, etc.
USE test INDEX test NEW // Use NEW in lieu of SELECT 0
// Prepare a beautiful color screen
// I do not like to put several commands in a single line
// but this is just to show what you can do with Clipper
SETCOLOR( "BG/B,GR+/B,,,BG/N" ); CLS
// Ok! Now is time to create a TBrowseDB object
// TBrowseDB( top, left, bottom, right ) ===> Object
b := TBrowseDB( 2, 2, 20, 48)
// This time, we will use and separators between columns and
// header
b:colSep := " │ "
// colSep contains an optional character used to draw a
// vertical separator if there is another column to the
// left of it.
b:headSep := "═╤═"
// headSep contains an optional character string used
// to draw a horizontal separator between the heading and
// data values
// Note that TBrowseDB() creates an object with no column
// objects. In order to make the object usable, a column must be
// added for each field to display.
// In this example we will use five fields.
// TBColumnNew( cHeading, bBlock ) =====> Object
column := TBColumnNew( "Field 1", {|| test->fld1} )
// Returns a new column object with specified heading and data
// retrieval block
b:addColumn( column )
// addColumn( objColumn ) =====> self
// Adds a new column object to the browse object and
// TBrowse:colCount is increased by one.
// Repeat the same to other fields
column := TBColumnNew( "Field 2", {|| test->fld2} )
b:addColumn( column )
column := TBColumnNew( "Field 3", {|| test->fld3} )
b:addColumn( column )
column := TBColumnNew( "Field 4", {|| test->fld4} )
b:addColumn( column )
column := TBColumnNew( "Field 5", {|| test->fld5} )
b:addColumn( column )
// It is time to put this programme to work
WHILE .T.
// Ok! It is time to stabilize display
// stabilize() =====> self
// Performs incremental stabilization. Stabilization is
// performed in increments so that it can be interrupted
// by any asynchronous event.
// A value of .T. is returned indicating the object is stable
WHILE ( !b:stabilize() )
nKey := InKey()
IF ( nKey != 0 )
EXIT // abort if a key is waiting
ENDIF
END
// b:stable contains .T. if the browse object is stable
// Display is stable
IF ( b:stable )
// everything's done; just wait for a key
nKey := INKEY(0)
ENDIF
// Up to this point nothing changed. But we need to include
// a keystroke handler. It will use cursor movement methods
// Process key
IF ( nKey == K_DOWN )
b:down()
ELSEIF ( nKey == K_UP )
b:up()
ELSEIF ( nKey == K_PGDN )
b:pageDown()
ELSEIF ( nKey == K_PGUP )
b:pageUp()
ELSEIF ( nKey == K_CTRL_PGUP )
b:goTop()
ELSEIF ( nKey == K_CTRL_PGDN )
b:goBottom()
ELSEIF ( nKey == K_RIGHT )
b:right()
ELSEIF ( nKey == K_LEFT )
b:left()
ELSEIF ( nKey == K_HOME )
b:home()
ELSEIF ( nKey == K_END )
b:end()
ELSEIF ( nKey == K_CTRL_LEFT )
b:panLeft()
ELSEIF ( nKey == K_CTRL_RIGHT )
b:panRight()
ELSEIF ( nKey == K_CTRL_HOME )
b:panHome()
ELSEIF ( nKey == K_CTRL_END )
b:panEnd()
ELSEIF ( nKey == K_ESC )
CLS; QUIT
ENDIF
// About cursor movement methods I strongly recommend you
// read the manual or the Guides
END
/* EOF - TTBR2.PRG */